﻿using System;
using System.Web.UI;
using LCA.Security;
using LCA.Common;

public partial class Common : MasterPage
{
	protected void Page_Load(object sender, EventArgs e)
	{
        html_tag.Attributes.Add("lang", System.Threading.Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName);
        ManagePermissions();
    }

    private void ManagePermissions()
    {
        LCAAuthentication.PerformPermissionCheck();

        // Top Links >>
        // If Viewer >> Can see only Flow + System 
        // If Power User >> Can see Flow + System + Admin
        // If Administrator >> Can see Flow + System + Admin

        lnkFlows.Visible = false;
        lnkSystems.Visible = false;
        lnkEdit.Visible = false;

        if (LCAAuthentication.IsLoggedIn())
        {
            lnkFlows.Visible = true;
            lnkSystems.Visible = true;

            if (!LCAAuthentication.IsRole(UserGroup.LCA_Viewer))
            {
                lnkEdit.Visible = true;
            }

            if (LCAAuthentication.IsRole(UserGroup.LCA_Administrator))
            {
                lnkEdit.InnerText = "Manage Users";
            }
        }
        else
        {
            lnkFlows.Visible = false;
            lnkSystems.Visible = false;
            lnkEdit.Visible = false;
        }

    }


}
